package com.freemix.freemix.configurer;

import org.springframework.http.server.ServerHttpRequest;
import org.springframework.web.socket.WebSocketHandler;
import org.springframework.web.socket.server.support.DefaultHandshakeHandler;

import java.security.Principal;
import java.util.Map;

public class CustomHandshakeHandler extends DefaultHandshakeHandler {
    
    @Override
    protected Principal determineUser(ServerHttpRequest request, WebSocketHandler wsHandler, 
                                    Map<String, Object> attributes) {
        // 从attributes中获取Principal
        return (Principal) attributes.get("PRINCIPAL");
    }
}